package com.akkainaction.remote.createremoteactor.byapi;

import akka.actor.*;
import akka.remote.RemoteScope;
import com.typesafe.config.ConfigFactory;

/**
 * 通过api创建远程actor
 */
public class Main {

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("sys", ConfigFactory.load("remote-client-byapi.conf"));
        //通过api方式创建远程actor
        Address addr = new Address("akka.tcp", "sys", "127.0.0.1", 2252);
        ActorRef userServerActor=system.actorOf(Props.create(UserServerActor.class).withDeploy(new Deploy(new RemoteScope(addr))));
        ActorRef clientActor = system.actorOf(Props.create(UserClientActor.class), "userClientActor");
        userServerActor.tell("hello user server",clientActor);
    }
}
